package com.cool4j.generator.bean;

import com.cool4j.generator.constant.Constants;
import com.cool4j.generator.util.DBUtil;
import com.cool4j.generator.util.StringUtil;

/**
 * 列信息实体
 *
 * @author Frank create on 16/1/8 20:14
 */
public class ColumnBean {

    /** 数据库中列名称 */
    private String name;

    /** 生成实体字段名称 */
    private String domainName;

    /** 生成实体字段类型 */
    private String domainType;

    /** get 方法 */
    private String getMethod;

    /** set 方法 */
    private String setMethod;

    /** 列数据类型 */
    private int type;

    /** 列中文注释 */
    private String comment;

    /** 列注释详细 */
    private String commentDetail;

    /** 是否主键 */
    private boolean isPrimary = false;

    /** 是否自增 */
    private boolean isAutoIncrement = false;

    /** 是否允许空 */
    private boolean isNullable = false;

    /** 是否为外键 */
    private boolean isForeignKey = false;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDomainName() {
        this.domainName = StringUtil.firstLower(StringUtil.underlineToHump(this.name));
        return domainName;
    }

    public void setDomainName(String domainName) {
        this.domainName = domainName;
    }

    public String getDomainType() {
        this.domainType = DBUtil.getColumnType(this.type);
        return domainType;
    }

    public void setDomainType(String domainType) {
        this.domainType = domainType;
    }

    public String getGetMethod() {
        this.getMethod = StringUtil.getSetMethodName(this.domainName, Constants.METHOD_TYPE_GET);
        return getMethod;
    }

    public void setGetMethod(String getMethod) {
        this.getMethod = getMethod;
    }

    public String getSetMethod() {
        this.setMethod = StringUtil.getSetMethodName(this.domainName, Constants.METHOD_TYPE_SET);
        return setMethod;
    }

    public void setSetMethod(String setMethod) {
        this.setMethod = setMethod;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getCommentDetail() {
        return commentDetail;
    }

    public void setCommentDetail(String commentDetail) {
        this.commentDetail = commentDetail;
    }

    public boolean isPrimary() {
        return isPrimary;
    }

    public void setPrimary(boolean primary) {
        isPrimary = primary;
    }

    public boolean isAutoIncrement() {
        return isAutoIncrement;
    }

    public void setAutoIncrement(boolean autoIncrement) {
        isAutoIncrement = autoIncrement;
    }

    public boolean isNullable() {
        return isNullable;
    }

    public void setNullable(boolean nullable) {
        isNullable = nullable;
    }

    public boolean isForeignKey() {
        return isForeignKey;
    }

    public void setForeignKey(boolean foreignKey) {
        isForeignKey = foreignKey;
    }
}
